*===============================================================================
* Do-file creates "Experimental Dataset: Effect of Violence on Days to M-Paisa Withdrawal"
* Appendix Table A14
*===============================================================================

clear 
set more off

cd "~/Dropbox/VFD/REStat_Native_Files/Stata_Files"
local output "~/Dropbox/VFD/REStat_Native_Files/Stata_Files/Output"

use cadg_master_NATIVE.dta, clear


xi: reg days_to_withdrawal violence_34 if sample_cash_outlier==0 & treat_final==1 & post==1, cl(employeenumber) 
est store col1
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "NO"
estadd local provFE "NO"
estadd local stratumFE "NO"
estadd local individFE "NO"

xi: reg days_to_withdrawal violence_34 i.ym if sample_cash_outlier==0 & treat_final==1 & post==1, cl(employeenumber) 
est store col2
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local provFE "NO"
estadd local stratumFE "NO"
estadd local individFE "NO"

xi: reg days_to_withdrawal violence_34 i.ym i.province if sample_cash_outlier==0 & treat_final==1 & post==1, cl(employeenumber) 
est store col3
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local provFE "YES"
estadd local stratumFE "NO"
estadd local individFE "NO"

xi: reg days_to_withdrawal violence_34 i.ym i.block_final if sample_cash_outlier==0 & treat_final==1 & post==1, cl(employeenumber) 
est store col4
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local provFE "-"
estadd local stratumFE "YES"
estadd local individFE "NO"

xi: xtreg days_to_withdrawal violence_34 i.ym i.block_final if sample_cash_outlier==0 & treat_final==1 & post==1, cl(employeenumber) fe i(employeenumber)
est store col5
estadd ysumm, mean prefix(in_sample_)
estadd local samplestr "Treat x Post"
estadd local monthFE "YES"
estadd local provFE "-"
estadd local stratumFE "-"
estadd local individFE "YES"


* Export to Latex
esttab col1 col2 col3 col4 col5 using "`output'/table_a14.tex", cells(b(fmt(%9.2f) star) se(par fmt(%9.2f))) ///
starlevels(* .1 ** .05 *** .01) style(tex) keep(violence_34) ///
stats(samplestr in_sample_mean N_clust N r2 monthFE provFE stratumFE individFE, fmt(0 2 0 0 2 0 0 0) label("Sample" "Mean Dep Var" "\# Employees" "\# Observations" "R-Squared" "Month FE" "Province FE" "Strata FE" "Employee FE")) ///
label title("Days to Withdrawal by Violence Expectations") replace
